<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>Document</title>
    <script type="text/javascript" src="js/vue.js"></script>
    <script type="text/javascript" src="js/axios.min.js"></script>
</head>
<body>
<div id="app">
    <input type="button" value="get" @click="getData1"/>
    <input type="button" value="get2" @click="getData2"/>
    <h2>{{emp.id}}</h2>
    <h2>{{emp.empname}}</h2>
</div>

<script>
    axios.interceptors.request.use((config) => {
        config.headers.token = 'abc'
        return config
    })

    let vm = new Vue({
        el: '#app',
        data: {
            emp: {},
        },
        methods: {
            getData1() {
                axios
                    .get('http://localhost:8080/data1')
                    .then((res) => (vm.emp = res.data.result))
            },
            getData2() {
                axios
                    .get('http://localhost:8080/data2')
                    .then((res) => (vm.emp = res.data.result))
            },
        },
    })
</script>
</body>
</html>
